<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of controller_login
 *
 * @author cs321ga3a
 */
class Controller_login extends CI_Controller {
    function __construct()
    {
        parent::__construct();
        $this->session->sess_destroy();

        $this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate, no-transform, max-age=0, post-check=0, pre-check=0");
        $this->output->set_header("Pragma: no-cache");

    }

    function index() {
        $data = array(      
            'title' => 'Login',
            'payload' => "",
            'view' => 'view_login',
        );
        $this->load->view('view_template', $data);
    }

    function doLogin(){
        extract($this->ajax->post("username","password"));

       // $this->load->model("model_user");

        //$this->model_user->login($username,$password);
        $this->login($username,$password);
        
    }
    
    function login($username ,$password){
        $this->db->where("user_login", $username);
        $this->db->where("user_password", $password);
        $query = $this->db->get("users");
        if ($query->num_rows() == 0){
            return null;
        }
        else{
            return $query->row();
        }
    }

    function getInfo() {
        $submitted = $this->input->post('submit');
        $username = $this->input->post('username');
        $extract(username);        
    }
    
}
?>
